import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ChatPrivate extends MyEvent {
	private JTextArea jtxtChatContent;
	private JTextArea jtxtMessage;
	private JButton jbtnSend;
	private JFrame jChatForm;
	private JScrollPane jscrollContent, jscrollMsg;

	public ChatPrivate(String username) {

		jChatForm = new JFrame(username);

		jtxtChatContent = new JTextArea(16, 44);
		jtxtChatContent.setEnabled(false);
		jtxtChatContent.setLineWrap(true);
		jscrollContent = new JScrollPane(jtxtChatContent);

		jtxtMessage = new JTextArea(4, 36);
		jtxtMessage.setLineWrap(true);
		jscrollMsg = new JScrollPane(jtxtMessage);

		jbtnSend = new JButton("Send");
		jbtnSend.setPreferredSize(new Dimension(80, 63));
		jbtnSend.addActionListener(this);
	}

	public void CreateGUI() {
		jChatForm.add(jscrollContent);
		jChatForm.add(jscrollMsg);
		jChatForm.add(jbtnSend);
		jChatForm.setSize(500, 368);
		jChatForm.setResizable(false);
		jChatForm.setLayout(new FlowLayout());
		jChatForm.setVisible(true);
	}

	/*public static void main(String[] args) {
		ChatPrivate chatform = new ChatPrivate();
		chatform.CreateGUI();
	}*/

	@Override
	public void actionPerformed(ActionEvent e) {
		if (jtxtMessage.getText().equals(""))
			return;
		if (e.getSource() == jbtnSend) {
			String chatContent = jtxtChatContent.getText();
			String message = jtxtMessage.getText();
			jtxtChatContent.setText(chatContent.equals("") ? message
					: chatContent + "\n" + message);
		}
		jtxtMessage.setText("");
	}
}
